
import resolve from 'rollup-plugin-node-resolve';
import babel from 'rollup-plugin-babel';
import eslint from 'rollup-plugin-eslint';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';

import uglify  from 'rollup-plugin-uglify';

const production = !process.env.ROLLUP_WATCH;

const plugins_for_browser = [
    commonjs(),
    json({
        preferConst: true,
        indent: ''
    }),
    babel({
        babelrc: false,
        exclude: 'node_modules/**',
        presets: [
            ['env', {
                targets: {
                    "browsers": ['ie >= 8']
                },
                modules: false,
                loose: true,
                debug: true
            }]
        ],
        plugins: ['external-helpers']
    }),
    resolve({
        jsnext: true,
        main: true,
        browser: true
    })
];

var plugins_for_sdk;
if (production) {
    plugins_for_sdk = plugins_for_browser.concat([uglify({
        compress: false,
        ie8: true
    })]);
    plugins_for_sdk.slice(3, eslint());
} else {
    plugins_for_sdk = plugins_for_browser;
}

export default [
  /*  {
        input: './src/html5/html5recorder.js',
        output: {
            file: './dist/html5recorder.umd.js',
            format: "umd"
        },
        name:'Html5recorder',
        plugins: plugins_for_sdk,
        sourcemap:true
    },*/
    {
        input: './src/aipanel.js',
        output: {
            file: './dist/chivox.umd.js',
            format: "umd"
        },
        name:'AiPanel',
        plugins: plugins_for_sdk,
        sourcemap:true
    }
   /* {
        input: './src/html5/html5recorder.js',
        output: [
            {
                file: './dist/html5recorder.cjs.js',
                format: "cjs"
            },
            {
                file: './dist/html5recorder.es.js',
                format: "es"
            }
        ],
        name:'Html5recorder',
        plugins: [json()],
    }*/
]



